home *** CD-ROM | disk | FTP | other *** search
- Path: nyssa.swt.edu!LN16674
- From: ln16674@nyssa.swt.edu (Leland Newsom)
- Newsgroups: comp.lang.c
- Subject: Re: reversing a string
- Date: 9 Apr 1996 17:38:14 GMT
- Organization: Southwest Texas State University
- Message-ID: <4ke7a6$49m@central.server.swt.edu>
- References: <4k6cjl$j8f@central.server.swt.edu> <4kb1s7$6eu@ibm32.perftech.com>,<829058514snz@genesis.demon.co.uk>
- Reply-To: ln16674@nyssa.swt.edu
- NNTP-Posting-Host: nyssa.swt.edu
-
- In article <829058514snz@genesis.demon.co.uk>, Lawrence Kirby <fred@genesis.demon.co.uk> writes:
- >In article <4kb1s7$6eu@ibm32.perftech.com>
- > murf@perftech.com "John Murphy" writes:
- >
- >>In article <4k6cjl$j8f@central.server.swt.edu>, ln16674@nyssa.swt.edu
- >>says...
- >>>
- >>>I have a challenge from a friend of mine. He wanted me to reverse a string
- >>>with recursion without using any additional variables or loops. I got mine
- >>>to work by using exclusive or, but I needed an additional variable. Can
- >>>someone help with this problem without using the additional variable?
- >>>
- >>>Thanks
- >>You can swap two variables, x and y, with the following series of exclusive
- >>or's:
- >> x ^= y;
- >> y ^= x;
- >> x ^= y;
- >
- >From what he wrote I believe Leland was already doing that. The problem is
- >to write the entire function without using an additional variable. It
- >can be done! :-)
- >
- >--
- >-----------------------------------------
- >Lawrence Kirby | fred@genesis.demon.co.uk
- >Wilts, England | 70734.126@compuserve.com
- >-----------------------------------------
-
-
-
- Yes, I was doing that. He said that it could be done without any extra
- variables. He also said that if you get real cryptic you can do the function
- in one or two lines.
-
- Thanks
- Leland
-
-